package com.ysxsoft.wdg.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.adapter.FragmentAdapter;
import com.ysxsoft.wdg.base.BaseFragment;
import com.ysxsoft.wdg.ui.fragment.th.KanFragment;
import com.ysxsoft.wdg.ui.fragment.th.ManFragment;
import com.ysxsoft.wdg.ui.fragment.th.TuanFragment;
import com.ysxsoft.wdg.widget.viewpager.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class THuiFragment extends BaseFragment {
    @BindView(R.id.topView)
    View topView;
    @BindView(R.id.title_finish)
    ImageView titleFinish;
    @BindView(R.id.title_content)
    TextView titleContent;
    @BindView(R.id.title_iv_r)
    ImageView titleIvR;
    @BindView(R.id.tv_tuan)
    TextView tvTuan;
    @BindView(R.id.tv_kan)
    TextView tvKan;
    @BindView(R.id.tv_man)
    TextView tvMan;
    @BindView(R.id.viewPager)
    NoScrollViewPager viewPager;

    private FragmentAdapter fmAdapter;
    private List<BaseFragment> fragments;


    @Override
    protected int getLayoutId() {
        return R.layout.fm_two;
    }

    @Override
    protected void initData() {
        initStatusBar(topView, false);

        titleFinish.setVisibility(View.GONE);
        titleIvR.setImageResource(R.mipmap.zy_search);
        titleContent.setText("特惠区");

        tvTuan.setSelected(true);

        fragments = new ArrayList<>();
        fragments.add(new TuanFragment());
        fragments.add(new KanFragment());
        fragments.add(new ManFragment());
        fmAdapter = new FragmentAdapter(getChildFragmentManager(),fragments);

        viewPager.setAdapter(fmAdapter);
        viewPager.setCurrentItem(0);

    }

    @Override
    protected void setListener() {
    }


    @OnClick({R.id.title_iv_r,R.id.tv_tuan, R.id.tv_kan, R.id.tv_man})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_iv_r:
                break;
            case R.id.tv_tuan:
                tvTuan.setSelected(true);
                tvKan.setSelected(false);
                tvMan.setSelected(false);
                viewPager.setCurrentItem(0);
                break;
            case R.id.tv_kan:
                tvTuan.setSelected(false);
                tvKan.setSelected(true);
                tvMan.setSelected(false);
                viewPager.setCurrentItem(1);
                break;
            case R.id.tv_man:
                tvTuan.setSelected(false);
                tvKan.setSelected(false);
                tvMan.setSelected(true);
                viewPager.setCurrentItem(2);
                break;
        }
    }
}
